package com.exigen.training;

import java.util.ArrayList;
import java.util.List;

public class VersionControlPractice {

	public static List<Thread> listThread = new ArrayList<Thread>();

	public static void main(String[] args) {
		
		printLine("Exigen-Mercurial-Practice").run();
		System.out.println();
		System.out.println("Arturs Vinogradovs");
		System.out.println("Rihards Fridrihsons");
		System.out.println("Gvido Neilands");
		System.out.println("Makisms Savchuks");
		System.out.println("Janis Zvirbulis");
		System.out.println("Anna Pinne");
		System.out.println("Silvestrs Aispurs");
		
		
		listThread.add(printLine("Guntars Dudelis"));
		listThread.add(eniLtnirp("I v a r s   Z i s b e r g s"));
		listThread.add(printLine("Guntars Paluhs"));

		runThreads();
	}
	
	public static void runThreads()
	{
		for (Thread thread : listThread) {
			try {
				thread.start();
				thread.join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println();
		}
	}

	public static Thread printLine(final String line) {
		Thread th = new Thread() {
			public void run() {
				for (int j = 0; j < line.length(); j++) {
					System.out.print(line.charAt(j));

					try {
						Thread.sleep(50);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		};

		return th;
	}
	public static Thread eniLtnirp(final String line) {
		Thread th = new Thread() {
			public void run() {
				for (int j = line.length() - 1; j >= 0; j--) {					
					System.out.print(line.charAt(j));
					try {
						Thread.sleep(50);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		};

		return th;
	}
}